package cn.gson.crm.controller.customer;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.gson.crm.controller.BaseServlet;
import cn.gson.crm.model.dao.ApplyDao;
import cn.gson.crm.model.dao.CustomerDao;
import cn.gson.crm.model.entity.Apply;
import cn.gson.crm.model.entity.Employee;
import cn.gson.crm.vo.CustomerVo;

/**
 * Servlet implementation class CustomerFormServlet
 */
@WebServlet("/cust/form")
public class CustomerFormServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void get(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Employee e = (Employee) request.getSession().getAttribute("emp");
		List<CustomerVo> listCust = new CustomerDao().getAllCustomer(e.getEmpId(),1);
		List<Apply> listApply = new ApplyDao().getAllNeedApplyByEmpId(e.getEmpId());
		request.getSession().setAttribute("listApply", listApply);
		request.getSession().setAttribute("custList", listCust);
		request.getSession().setAttribute("listCust", listCust.size());
		forward("customer/customer_form.jsp");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void post(HttpServletRequest request, HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
